package com.uama.image;

import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.AppCompatActivity;

import com.facebook.drawee.view.SimpleDraweeView;
import com.uama.image.ImagePreview.ImagePreviewPopup;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class MainActivity extends AppCompatActivity {
    public static final String webp1 = "https://isparta.github.io/compare-webp/image/gif_webp/webp/1.webp";
    public static final String pic = "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1510130251924&di=658fa3388d572f1516d3936efe6cbb8c&imgtype=0&src=http%3A%2F%2Fwww.9553.com%2Fupload%2Finfo%2F2015%2F0915%2F20150915014214349.jpg";
    @BindView(R.id.img_webp1)
    SimpleDraweeView imgWebp1;
    @BindView(R.id.img_webp2)
    SimpleDraweeView imgWebp2;
    @BindView(R.id.img_webp3)
    SimpleDraweeView imgWebp3;
    @BindView(R.id.img_test)
    SimpleDraweeView imgTest;

    private ArrayList<String> urls;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        urls = new ArrayList<>();
        urls.add("http://h.hiphotos.baidu.com/image/pic/item/c8177f3e6709c93def092e33953df8dcd000547e.jpg");
        urls.add("http://a.hiphotos.baidu.com/image/pic/item/503d269759ee3d6d1d94500849166d224e4adea7.jpg");
        String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/Pictures/test.jpg";
        ImageLoader.getInstance().load(imgWebp1, R.drawable.hello);
        ImageLoader.getInstance().load(imgWebp2, R.drawable.move);

        ImageLoader.getInstance().load(imgWebp3, path);
        ImageLoader.getInstance().load(imgTest, webp1);

    }

    @OnClick(R.id.btn_image_preview)
    public void onViewClicked() {
        ImagePreviewPopup popup = new ImagePreviewPopup(this, urls, 1);
        popup.show();
    }
}
